package com.zzl.bonds.ticket.constant.status;

import java.util.HashMap;
import java.util.Map;

/**
 * 票据兑付状态枚举类
 *
 * @author szsw
 * @date 2021/11/30 17:04:58
 */
@SuppressWarnings("unused")
public enum TicketCashingEnum {

    /**
     *
     */
    ALL                     (0, "全部", "所有兑付状态"),
    OUTSTANDING             (1, "未兑付", "核心企业还没有兑付"),
    WAITING_FOR_PAYMENT     (2, "等待兑付", "预兑付时票据处于的兑付状态"),
    CASHED                  (3, "已兑付", "核心企业兑付完成"),
    OVERDUE_NON_PAYMENT     (4, "逾期未兑付", "票据预期，尚未兑付"),
    OVERDUE_CASHED          (5, "逾期已兑付", "票据预期，但是在预期后完成了兑付"),
    APPROVE_CASHED          (6, "兑付审批中", "提前兑付,待平台审批")
    ;

    private Integer code;
    private String name;
    private String description;

    TicketCashingEnum(Integer code, String name, String description) {
        this.code = code;
        this.name = name;
        this.description = description;
    }

    /**
     * 获取所有兑付状态字典值
     *
     * @return 兑付状态集合，map.key->code；map.value->name
     */
    public static Map<Integer, String> ticketCashingList() {
        TicketCashingEnum[] values = TicketCashingEnum.values();
        Map<Integer, String> result = new HashMap<>(values.length);
        for (TicketCashingEnum value : values) {
            result.put(value.code, value.name);
        }
        return result;
    }

    /**
     * 通过code获取枚举对象
     *
     * @param code code值
     * @return 枚举对象
     */
    public static TicketCashingEnum getStatus(Integer code) {
        for (TicketCashingEnum value : TicketCashingEnum.values()) {
            if(value.code.equals(code)){
                return value;
            }
        }
        return null;
    }

    /**
     * 获取所有兑付状态字典值
     *
     * @return 兑付状态集合，map.key->code；map->enum
     */
    public static Map<Integer, TicketCashingEnum> ticketCashingEnumList() {
        TicketCashingEnum[] values = TicketCashingEnum.values();
        Map<Integer, TicketCashingEnum> result = new HashMap<>(values.length);
        for (TicketCashingEnum value : values) {
            result.put(value.code, value);
        }
        return result;
    }

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public String getDescription() {
        return description;
    }
}
